package com.teatrace.service.sell.impl;

import java.util.List;

import com.teatrace.dao.BaseDao;
import com.teatrace.dao.template.DaoCallBack;
import com.teatrace.dao.template.DaoTemplate;
import com.teatrace.dao.template.impl.AutoTransactionDaoTemplate;
import com.teatrace.service.sell.SellService;

public class SellServiceImpl implements SellService {

	private DaoTemplate getAutoTransactionDaoTemplate() {
		return new AutoTransactionDaoTemplate();
	}
	
	@SuppressWarnings("unchecked")
	public <T> List<T> listObject(final Class<T> clazz) throws Exception {
		return (List<T>) this.getAutoTransactionDaoTemplate().execute(new DaoCallBack() {
			public Object doInDao(BaseDao dao) throws Exception {
				return dao.list(clazz);
			}
		});
	}

	public void deleteObject(final Class clazz) throws Exception {
		this.getAutoTransactionDaoTemplate().execute(new DaoCallBack() {
			public Object doInDao(BaseDao dao) throws Exception {
				dao.delete(clazz);
				return null;
			}
		});
	}

}
